<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\recruitmentEnterprise\controller;

use plugin\saiadmin\basic\BaseController;
use app\recruitmentEnterprise\logic\recruitmentEnterpriseLogic;
use app\recruitmentEnterprise\validate\recruitmentEnterpriseValidate;
use support\Request;
use support\Response;

/**
 * 招聘企业控制器
 */
class recruitmentEnterpriseController extends BaseController
{
    /**
     * 数据表主键
     */
    protected $pk = 'enterprise_id';
    
    /**
     * 构造函数
     */
    public function __construct()
    {
        $this->logic = new recruitmentEnterpriseLogic();
        $this->validate = new recruitmentEnterpriseValidate;
        parent::__construct();
    }

    /**
     * 数据列表
     * @param Request $request
     * @return Response
     */
    public function index(Request $request): Response
    {
        $where = $request->more([
            ['enterprise_name', ''],
            ['contact_person', ''],
            ['contact_number', ''],
            ['lang_code', ''],
        ]);
        $query = $this->logic->search($where);
        $data = $this->logic->getList($query);
        return $this->success($data);
    }
    public function getSelect(Request $request){
        $where = $request->more([
            ['lang_code', ''],
        ]);
        $data = $this->logic->where($where)
        ->field('enterprise_id as value,enterprise_name as label')
        ->order('enterprise_id desc')  // 增加排序保证结果一致性
        ->select()
        ->toArray();
        return $this->success($data);
    }
   public function export(Request $request) : Response
    {
       
         $where = $request->more([
            ['enterprise_name', ''],
            ['contact_person', ''],
            ['contact_number', ''],
            ['lang_code','zh']
        ]);
        return $this->logic->export($where);
    }
}
